{include 'header.tpl'}
<div class="contant">
    <div class="header">
        <div class="header_s">
            <span class="back"><a href="javascript:history.go(-1)"><i class="iconfont fan">&#xe679;</i></a></span>
            <span class="title">收货地址</span>
            <span class="add_ads"></span>
            <div class="clear"></div>
        </div>
    </div>
    <div data-role="container" class="container ordercreates">
        <div class="new-ct">
            <div class="new-addr">
                {if $dataList}
                <ul class="new-mu_l2w">
                    {foreach from=$dataList item=item}
                        <li class="new-mu_l2 cf" data-id="{$item.auto_id}">
                            {if $item.is_default eq '1'}<div class="news_left"><img src="/mall2/images/check.png"></div>{/if}
                            <div class="news_center">
                                <p class="new-tit new-p-re">
                                    <span class="new-txt {if $item.is_default eq '1'}darv_red{/if}"> {$item.contact}</span>
                                    <span class="new-txt-rd2 {if $item.is_default eq '1'}darv_red{/if}">{$item.phone}</span>
                                </p>
                                <span class="new-mu_l2a new-p-re">
                                    <span class="new-mu_l2cw">{$item.province}{$item.city}{$item.county}{$item.address}{$item.housemember}</span>
                                </span>
                            </div>
                            <div class="news_rg">
                                <a href="/address/save?id={$item.auto_id}&refer={$refer}"><img src="/mall2/images/edit.png"></a>
                            </div>
                        </li>
                    {/foreach}
                </ul>
                {else}
                    <div id="list_order" class="list_order">
                        <div class="order_p">
                            <h5>你还没有添加地址</h5>
                            <p>小红薯等您来翻牌哦</p>
                        </div>
                        <div class="order_btn"><a href="/address/save?refer={$refer}">添加地址</a></div>
                    </div>
                {/if}
                <a target="_blank" href="/address/save?refer={$refer}" class="add_adress">添加新地址</a>
            </div>
        </div>

    </div>
</div>
<script>
    $(function () {
        var refer = '{$refer}';
        $('.news_center').click(function () {
            var li = $(this).closest('li');
            if(li.find('.news_left').length != 1){
                var active_li = $('.news_left').closest('li');
                $('.news_left').remove();
                active_li.find('.darv_red').removeClass('darv_red');
                $(this).before('<div class="news_left"><img src="/mall2/images/check.png"></div>');
                $(this).find('.new-tit span').addClass('darv_red');
                $.post('/address/resetDefault',{ id:li.data('id')},function(res){
                    if(refer) window.location.href = refer;
                });
            }else{
                if(refer) window.location.href = refer;
            }
        });
    });
</script>
{include 'footer.tpl'}